package cnpm02.j2ee.group3.logic.model;

import org.jboss.seam.Component;

import cnpm02.j2ee.group3.logic.utils.ATSMUtils;
import cnpm02.j2ee.group3.model.FlightLine;
import cnpm02.j2ee.group3.model.SoldTicket;

/**
 * Contain suitable data for the UI (xhtml) uses
 * @author BINH
 * @version 1.0 
 * */
public class SoldTicketDTO {
	private static final String SPLASH = "/";
	private long soldTicketId;
	private String customerName;
	private String phoneNumber;
	private String email;
	private String from_To;
	private String quantity;
	private String price;
	private String status;
	
	public SoldTicketDTO(SoldTicket soldTicket) throws Exception {
		ATSMUtils atsmUtils = (ATSMUtils) Component.getInstance("atsmUtils");
		FlightLine fl = soldTicket.getTicket().getFlight().getFlightLine();
		this.setSoldTicketId(soldTicket.getId());
		this.customerName = soldTicket.getCustomer().getFirstname();
		this.phoneNumber = soldTicket.getCustomer().getPhoneNumber().toString();
		this.email = soldTicket.getCustomer().getEmail();
		this.from_To = atsmUtils.translate(fl.getFrom()) + SPLASH
				+ atsmUtils.translate(fl.getTo());
		this.quantity = String.valueOf(soldTicket.getQuantity());
		this.price = atsmUtils.formatMoney(soldTicket.getPrice());
		this.status = soldTicket.getStatus().getNameByLanguage(
				atsmUtils.getCurrentLanguage());
	}
	
	public String getCustomerName() {
		return customerName;
	}
	
	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}
	
	public String getFrom_To() {
		return from_To;
	}
	
	public void setFrom_To(String from_To) {
		this.from_To = from_To;
	}
	
	public String getPrice() {
		return price;
	}
	
	public void setPrice(String price) {
		this.price = price;
	}
	
	public String getStatus() {
		return status;
	}
	
	public void setStatus(String status) {
		this.status = status;
	}
	
	public void setQuantity(String quantity) {
		this.quantity = quantity;
	}
	
	public String getQuantity() {
		return quantity;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getEmail() {
		return email;
	}

	public void setSoldTicketId(long soldTicketId) {
		this.soldTicketId = soldTicketId;
	}

	public long getSoldTicketId() {
		return soldTicketId;
	}

}
